home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 050 / madtrb9.arc / UT-MOD03.INC < prev    next >
Text File  |  1985-12-11  |  5KB  |  153 lines

  1.  procedure Prompt(Line1,Line2: str255);
  2.     { Display prompt lines on bottom 2 lines of Video }
  3.   begin
  4.     gotoXY(1,23); ClrEol; writeln(Line1); ClrEol; write(Line2);
  5.   end;
  6.  
  7. procedure Say_Prompt(Prompt_num : integer);
  8.    { Programmer defined prompts for bottom 2 lines of Video }
  9.  var Line1,Line2 : string[80];
  10.  begin
  11.    Line2 := 'Press <F1> to change the last entry';
  12.    Case Prompt_num of
  13.      1 : Line1 := '';
  14.      2 : begin
  15.            Line1 := 'Enter anything you wish or';
  16.            Line2 := 'Press the <F1> key to exit this section...';
  17.          end;
  18.      3 : Line1 := 'This is the second prompt';
  19.      4 : Line1 := 'All prompts are programmer defined';
  20.      5 : Line1 := 'This is the last prompt';
  21.    end;
  22.    prompt(Line1,Line2);
  23.  end;
  24.  
  25. procedure Get_Default(Default_num : integer; var Default : str80);
  26.   { Default values for the Input_Handler are handled here }
  27.  begin
  28.    Case Default_num of
  29.      1 : Default := '';
  30.      2 : Default := FilVar[1];
  31.    end;
  32.  end;
  33.  
  34. procedure Do_Validation(Valid_num : integer; var Valid : boolean);
  35.    { Validation of user inputs is done here }
  36.  var S : str80;
  37.   Cd,I : integer;
  38.      N : Real;
  39.  begin
  40.    Valid := true;
  41.    Case Valid_num of
  42.      1 : ;
  43.      2 :begin
  44.          val(copy(Answer,4,2),I,Cd); if I>31 then Valid := false;
  45.         end;
  46.      3 :begin
  47.         end;
  48.    end; { case }
  49.  end;   { procedure }
  50.  
  51.  
  52. procedure Input_Handler(IpCode: str5; var Escape: boolean);
  53.   { Handles all input and editing for a page of inputs }
  54.   { requires procedures
  55.                Say_Prompt, Do_Validation, Get_Default
  56.           global variables
  57.                Filvar: array of [1..25] of string[80] }
  58.  label  100;
  59.  
  60.  var Typ,IpType,uppercase     : Char;
  61.      Default,Template         : str80;
  62.  
  63.      Row,Col,Mlen,I,Code,Count,
  64.      First_var_num,Last_var_num,
  65.      Filvar_num,
  66.      Default_num,Prompt_num,Validation_num  : integer;
  67.  
  68.      F1,F10,Valid,UCase : boolean;
  69.  
  70.   procedure Get_Var;
  71.     begin
  72.       val(copy(P[count],1,2), Col,Code);
  73.       val(copy(P[count],3,2), Row,Code);
  74.       Typ := copy(P[count],5,1);
  75.       val(copy(P[count],6,3), Mlen,Code);
  76.       val(copy(P[count],9,2), Filvar_num,Code);
  77.       upperCase := copy(P[count],11,1);
  78.       val(copy(P[count],12,2),Default_num,Code);
  79.       val(copy(P[count],14,2),Prompt_num,Code);
  80.       val(copy(P[count],16,2),Validation_num,Code);
  81.       if upperCase= 'T' then UCase:= true else UCase:= false;
  82.     end;
  83.  
  84.   procedure Display_Rec;
  85.    var I : integer;
  86.    begin
  87.      HighVideo;
  88.      for I:= first_var_num to last_var_num do
  89.       begin
  90.         if typ <> 'N' then
  91.         begin
  92.           Count:= I; Get_Var;
  93.           gotoXY(col,row); write(Filvar[Filvar_num]);
  94.         end;
  95.       end; { for loop }
  96.    end;
  97.  
  98.  begin
  99.    IpType := copy(IpCode,1,1);
  100.    val(copy(IpCode,2,2),First_Var_num,Code);
  101.    val(copy(Ipcode,4,2),Last_var_num,Code);
  102.    Case IpType of
  103.      'N' : for I:= 1 to 25 do Filvar[I] := '';
  104.      'C' : ;
  105.    end; { Case }
  106.    count := First_var_Num; F1:=false; F10:=false;
  107.    if IpType = 'D' then Display_rec
  108.    else
  109.    begin
  110.      if IpType = 'C' then
  111.      begin
  112.        gotoXY(1,25);clreol;
  113.        InvVideo('Press  <F10>  to EXIT changes  or  <Esc> to change an entry');
  114.        Say_Cap_num;
  115.      end;
  116.      repeat
  117.        Get_Var; template:='';
  118.     100: if Filvar[count] = '' then Get_Default(Default_num,Default)
  119.        else Default := Filvar[count];
  120.        HighVideo; Say_Prompt(Prompt_num);
  121.  
  122.        Input(Typ,Default,Col,Row,Mlen,UCase,F1,F10);
  123.            { F1 and F10 is returned from Input }
  124.  
  125.        if (IpType = 'C') and (F10) then
  126.          begin Exit := true; F10:= false; end
  127.        else
  128.        begin
  129.          Do_validation(Validation_num,Valid);
  130.          {Valid returned from Do_Validation: if not Valid then entry is redone}
  131.          if not valid then
  132.           begin
  133.             Default:=''; Filvar[count]:='';  Beep(350,150);
  134.             goto 100;   { 100 is the input procedure above (in this procedure) }
  135.           end;     { do not use default }
  136.          Filvar[count] := Answer;
  137.          if F1 then
  138.          begin
  139.            gotoXY(col,row); HighVideo;
  140.            if Filvar[count]<>''then write(Filvar[count])
  141.             else write(template);
  142.            count:=count-1; F1:=false;
  143.          end else  count:=count+1;
  144.          if count<First_var_num then begin Escape:=true;  Exit:=true; end else
  145.          if count>Last_var_num  then begin Escape:=false; Exit:=true; end else
  146.          Exit:=false;
  147.        end;
  148.      until Exit = true;
  149.      if count > first_var_num then Escape:= false;
  150.      if IpType = 'C' then begin gotoXY(1,25); clreol; end;
  151.    end; { typ <> 'D' }
  152.    Exit:=false;
  153.  end;